package com.feidee.fd.sml.algorithm.feature

import com.feidee.fd.sml.algorithm.component.feature.{BinarizeEncoder, BinarizeEncoderParam}
import com.feidee.fd.sml.algorithm.util.{TestingDataGenerator, ToolClass}
import org.scalatest.FunSuite

/**
  * @Author JunxinWang
  * @Date 2019/3/27 15:45
  * @Description
  * @Reviewer YongChen
  */
class BinarizeEncoderSuite extends FunSuite {

  val bin = new BinarizeEncoder()
  val paramStr: String =
    """
      |{
      | "inputCol": "feature"
      |}
    """.stripMargin
  val param: BinarizeEncoderParam = bin.parseParam(new ToolClass().encrypt(paramStr))

  test("tokenizer parameter construction test") {
    assert(param.input_pt == null && param.output_pt == null && param.modelPath == null &&
      "feature".equals(param.inputCol) && param.threshold==0.0)
  }

  test("tokenizer transforming function test") {
    import TestingDataGenerator.spark.implicits._
    val rawData = Seq((0, -0.1), (1, 0.8), (2, 0.2)).toDF("id","feature")

    val binData = bin.train(param, rawData).transform(rawData)
    binData.show()
  }
}
